# -*- coding: utf-8 -*-
"""
积分系统 - Django Admin配置
"""

from django.contrib import admin
from .models import PointRecord, PointProduct, PointExchange, DailyCheckin


@admin.register(PointRecord)
class PointRecordAdmin(admin.ModelAdmin):
    """积分记录管理"""
    list_display = ('user', 'points', 'type', 'balance_after', 'created_at')
    list_filter = ('type', 'created_at')
    search_fields = ('user__username', 'description')
    raw_id_fields = ('user', 'related_activity', 'related_product')
    ordering = ('-created_at',)


@admin.register(PointProduct)
class PointProductAdmin(admin.ModelAdmin):
    """积分商品管理"""
    list_display = ('name', 'type', 'points_required', 'stock', 'exchange_count', 'status', 'created_at')
    list_filter = ('type', 'status', 'created_at')
    search_fields = ('name', 'description')
    ordering = ('-sort_order', '-created_at')


@admin.register(PointExchange)
class PointExchangeAdmin(admin.ModelAdmin):
    """积分兑换管理"""
    list_display = ('user', 'product', 'points_spent', 'quantity', 'status', 'created_at')
    list_filter = ('status', 'created_at')
    search_fields = ('user__username', 'product__name')
    raw_id_fields = ('user', 'product')


@admin.register(DailyCheckin)
class DailyCheckinAdmin(admin.ModelAdmin):
    """每日签到管理"""
    list_display = ('user', 'checkin_date', 'points_earned', 'consecutive_days', 'created_at')
    list_filter = ('checkin_date', 'created_at')
    search_fields = ('user__username',)
    raw_id_fields = ('user',)
    ordering = ('-checkin_date', '-created_at')
